#!/usr/bin/python
#
#   Copyright (C) 2004
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Lesser General Public
#   License as published by the Free Software Foundation; either
#   version 2.1 of the License, or (at your option) any later version.
#
#   This library is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   Lesser General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public
#   License along with this library; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""Portal forms __init__.
$Id: reppy.py,v 0.1 2004/10/29 20:19:20 wbauer Exp $
"""
__version__='$Revision: 0.1 $'[11:-2]

import sys
import repParser
import error

templatename = ""
folder=""

db = {}
for f in sys.argv:  # read arguments from commandline
	if f[0:2] == "-f":
		templatename = f[2:]
	if f[0:2] == "-h":
		db['host'] = f[2:]
	if f[0:2] == "-u":
		db['user'] = f[2:]
	if f[0:2] == "-p":
		db['password'] = f[2:]
	if f[0:2] == "-d":
		db['database'] = f[2:]
	if f[0:2] == "-o":
		db['filename'] = f[2:]
	if f[0:2] == "-v":
		folder = f[2:]

if templatename == "":   # no template given -> report not defined
	print "========================================="
	print "usage: python reppy.py -f<templatename> "
	print "optional arguments are:"
	print "   -h<hostname>  name of the database server"
	print "   -u<username>  name of db user "
	print "   -p<password>  password of db-user"
	print "   -d<databasename> name of database with mysql or postgres"
	print "   -o<pdf-filename> name of output pdf-file"
	print "   -v<foldername> name of the folder, where all report-templates are stored."
else:
	error.setDestination(error.DESTCONSOLE)
	repParser.create_rep(templatename, db, folder)   # create report
